<template>
  <div class="dialog-email">
    <el-dialog :visible.sync="dialogVisible" width="500px" :close-on-click-modal="false" :close-on-press-escape	='false'
               title="回复邮件" center>
      <div class="content">
        <ul>
          <li>您是密送的收件人，如回复全部，则其他收件人会知道</li>
          <li>您收到了此邮件！是否要回复全部收件人？</li>
        </ul>
        <div class="btn-group">
          <el-button size="small" type="primary" @click="rollBackAll">回复全部</el-button>
          <el-button size="small" type="primary" @click="rollBack">回复发件人</el-button>
          <el-button size="small" @click="dialogVisible=false">取 消</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {mapState} from 'vuex'
    export default {
        name: "DialogEmail",
        data() {
            return {
                dialogVisible: false,
                content:{},
                temailInfoId:''
            }
        },
        computed:{
            ...mapState(['common'])
        },
        methods: {
            init(email,temailInfoId) {
                this.content=email;
                this.temailInfoId=temailInfoId;
                this.dialogVisible = true;
            },
            //回复
            rollBack(){
                this.$emit('rollBack')
                this.dialogVisible = false;
            },
            getEndEmail() {
                let emailCarbonCopy = this.content.emailCarbonCopy ? this.content.emailCarbonCopy.split(',') : [];//目标抄送数组
                let str = `<br><br><br>---------------- Original ----------------<br><div class="previous" style="color: #000000;font-size: 14px;font-family: Arial;line-height: 1.7;margin-bottom: 20px;background-color: #dddddd45;
    padding: 0 5px;">From: ${this.content.senderEmail}<br>Date: ${this.content.sendTime}<br>To:${this.filterStr(this.content.addresseeEmailArray).join(";")}`;
                if (emailCarbonCopy.length > 0) {
                    let cc = `<br>CC:${this.filterStr(emailCarbonCopy).join(";")}`;
                    str += cc;
                }
                const subject = `<br>Subject: ${this.content.emailSubject}</div>`;
                str += subject;
                return str;
            },
            filterStr(arrOld){
                let arr=[];
                arrOld.map((item, index) => {
                    if (item.indexOf('<') != -1) {//<1749846095@qq.com>
                        item = item.split('<')[1];
                        item = item.split('>')[0];
                    }
                    arr.push(item);
                })
                return arr;
            },
            //回复全部
            rollBackAll(){
                this.$emit('toBack',1)
                this.dialogVisible = false;
            }
        }
    }
</script>

<style scoped lang="scss">
  .dialog-email {
    .content {
      width: 350px;
      margin: 20px auto 50px;
      li{
        color: #232323;
        font-size: 14px;
        line-height: 30px;
        text-align: center;
      }
      .btn-group {
        display: flex;
        justify-content: space-between;
        margin: 20px 0 30px 0;
        .el-button{
          width: 100px;
          font-size: 15px;
        }
      }
    }
  }
</style>
